from datetime import datetime
from pydantic import Field
from schema.response.confBaseModel import ConfBaseModel


class UserResponse(ConfBaseModel):
    id: int  = Field(..., description="用户id")
    username: str = Field(..., description="用户名")
    create_time: datetime = Field(..., description="创建时间")
    update_time: datetime = Field(..., description="更新时间")
    sign_in: int = Field(..., description="今天是否签到 1 签到 0 未签到")

    def __init__(self, *args, **kwargs):
        """接受参数，实力化该类，采用这种方式主要想直接从user中生成(考虑合理性或更好的解决办法)
        """
        super().__init__(*args, **kwargs)

    class Config:
        from_attributes = True


class LoginResponse(ConfBaseModel):
    token: str = Field(..., description="token")
    user: UserResponse = Field(..., description="用户信息")



class GlodCoinsInfoResponse(ConfBaseModel):
    id: int = Field(..., description="id")
    gold_coins: int = Field(..., description="金币数量")
    gold_coins_type: int = Field(..., description="金币类型")
    text: str = Field(..., description="金币类型描述")
    create_time: str = Field(..., description="创建时间")
    update_time: str = Field(..., description="更新时间")

    class Config:
        from_attributes = True


class GlodCoinsLogResponse(ConfBaseModel):
    id: int = Field(..., description="id")
    gold_coins_info: GlodCoinsInfoResponse = Field(..., description="金币信息")
    source_user: UserResponse = Field(..., description="来源用户")
    target_user: UserResponse = Field(..., description="目标用户")
    blog_id: int = Field(..., description="博客id")
    create_time: str = Field(..., description="创建时间")
    update_time: str = Field(..., description="更新时间")

    class Config:
        from_attributes = True


class UserGoldLogResponse(ConfBaseModel):
    id: int = Field(..., description="id")
    text: str = Field(..., description="信息")
    create_time: datetime = Field(..., description="创建时间")

